package abs.web.jsf;

import abs.dao.CompaniasDAO;
import abs.dao.DocumentosDAO;

import abs.domain.Companias;
import abs.domain.Documentos;

import abs.service.DocumentosService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

import org.springframework.transaction.annotation.Transactional;

/**
 * Spring Component that handles CRUD requests for Documentos entities
 * 
 */
@Scope("session")
@Component("DocumentosComponent")
public class DocumentosComponentImpl implements DocumentosComponent {

	/**
	 * Data type variable that provides CRUD operations for Documentos entities
	 * 
	 */
	private Documentos documentos;

	/**
	 * DAO injected by Spring that manages Companias entities
	 * 
	 */
	private Companias companias;

	/**
	 * DAO injected by Spring that manages Companias entities
	 * 
	 */
	@Autowired
	private CompaniasDAO companiasDAO;

	/**
	 * DAO injected by Spring that manages Documentos entities
	 * 
	 */
	@Autowired
	private DocumentosDAO documentosDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for Documentos entities
	 * 
	 */
	@Autowired
	private DocumentosService documentosService;

	/** 
	 */
	public DocumentosComponentImpl() {
	}

	/**
	 * Create a new Documentos entity
	 * 
	 */
	@Transactional
	public String newDocumentos() {
		documentos = new Documentos();

		return "/jsf/documentos/createDocumentos.xhtml";
	}

	/**
	 * Save an existing Documentos entity
	 * 
	 */
	@Transactional
	public String saveDocumentos(Documentos documentos) {
		documentosService.saveDocumentos(documentos);
		return "/jsf/documentos/listDocumentoss.xhtml";
	}

	/**
	 * Get Companias entity by Documentos
	 * 
	 */
	@Transactional
	public Companias getDocumentosCompanias(String co030codiKey) {
		return documentosDAO.findDocumentosByPrimaryKey(co030codiKey).getCompanias();
	}

	/**
	 * Delete an existing Documentos entity
	 * 
	 */
	@Transactional
	public String deleteDocumentos(String co030codiKey) {
		Documentos documentos = documentosDAO.findDocumentosByPrimaryKey(co030codiKey);
		documentosService.deleteDocumentos(documentos);
		return "/jsf/documentos/listDocumentoss.xhtml";
	}

	/**
	 * Getter for variable Documentos
	 * 
	 */
	@Transactional
	public Companias getCompanias() {
		return companias;
	}

	/**
	 * Edit an existing Documentos entity
	 * 
	 */
	@Transactional
	public String editDocumentos(String co030codiKey) {
		documentos = documentosDAO.findDocumentosByPrimaryKey(co030codiKey);

		return "/jsf/documentos/editDocumentos.xhtml";
	}

	/**
	 * Show all Documentos entities
	 * 
	 */
	@Transactional
	public List<Documentos> listDocumentoss() {
		return new java.util.ArrayList<Documentos>(documentosService.loadDocumentoss());
	}

	/**
	 * Edit an existing Companias entity
	 * 
	 */
	@Transactional
	public String editDocumentosCompanias(String documentos_co030codi, String related_companias_co000nocia) {
		companias = companiasDAO.findCompaniasByPrimaryKey(related_companias_co000nocia, -1, -1);
		return "/jsf/documentos/companias/editCompanias.xhtml";
	}

	/**
	 * Getter for variable Documentos
	 * 
	 */
	@Transactional
	public Documentos getDocumentos() {
		return documentos;
	}

	/**
	 * Save an existing Companias entity
	 * 
	 */
	@Transactional
	public String saveDocumentosCompanias(String documentos_co030codi, Companias companias) {
		documentos = documentosService.saveDocumentosCompanias(documentos_co030codi, companias);

		return "/jsf/documentos/viewDocumentos.xhtml";
	}

	/**
	 * View an existing Companias entity
	 * 
	 */
	@Transactional
	public String selectDocumentosCompanias(String documentos_co030codi, String related_companias_co000nocia) {
		companias = companiasDAO.findCompaniasByPrimaryKey(related_companias_co000nocia, -1, -1);
		return "/jsf/documentos/companias/viewCompanias.xhtml";
	}

	/**
	 * Select an existing Documentos entity
	 * 
	 */
	@Transactional
	public String selectDocumentos(String co030codiKey) {
		documentos = documentosDAO.findDocumentosByPrimaryKey(co030codiKey);

		return "/jsf/documentos/viewDocumentos.xhtml";
	}

	/**
	 * Select the Documentos entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteDocumentos(String co030codiKey) {
		documentos = documentosDAO.findDocumentosByPrimaryKey(co030codiKey);

		return "/jsf/documentos/deleteDocumentos.xhtml";
	}

	/**
	 * Delete an existing Companias entity
	 * 
	 */
	@Transactional
	public String deleteDocumentosCompanias(String documentos_co030codi, String related_companias_co000nocia) {
		documentos = documentosService.deleteDocumentosCompanias(documentos_co030codi, related_companias_co000nocia);

		return "/jsf/documentos/viewDocumentos.xhtml";
	}

	/**
	 * Create a new Companias entity
	 * 
	 */
	@Transactional
	public String newDocumentosCompanias(String documentos_co030codi) {
		companias = new Companias();

		return "/jsf/documentos/companias/createCompanias.xhtml";
	}

	/**
	 * Select the child Companias entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteDocumentosCompanias(String documentos_co030codi, String related_companias_co000nocia) {
		companias = companiasDAO.findCompaniasByPrimaryKey(related_companias_co000nocia);

		return "/jsf/documentos/companias/deleteCompanias.xhtml";
	}

}
